package mo.leetcode_top;

public class L1221 {

    public int balancedStringSplit(String s) {

        int rCount = 0;
        int lCount = 0;
        int res = 0;

        for (char c : s.toCharArray()) {
            if (c == 'R') {
                rCount++;
            } else {
                lCount++;
            }
            if (rCount == lCount) {
                res++;
            }
        }
        return res;
    }


    public static void main(String[] args) {
        L1221 tes = new L1221();
        System.out.println(tes.balancedStringSplit("LLLLRRRR"));
    }
}
